//
//  JiHuoMaView.m
//  wangzhe
//
//  Created by 李 佳伟 on 2017/11/6.
//  Copyright © 2017年 李 佳伟. All rights reserved.
//

#import "JiHuoMaView.h"

#import "JTCSM.h"
static JiHuoMaView *single = nil;

@interface JiHuoMaView ()
@property (nonatomic,strong) UILabel *changciLabel;
@end

@implementation JiHuoMaView

+ (JiHuoMaView *)shareSingle
{
    @synchronized(self){
        if(single == nil){
            single =[ [JiHuoMaView alloc] init];
        }
        
    }
    return single;
}

/*
 // Only override drawRect: if you perform custom drawing.
 // An empty implementation adversely affects performance during animation.
 - (void)drawRect:(CGRect)rect {
 // Drawing code
 }
 */
- (id)init{
    self = [super init];
    if (self) {
        self.frame = CGRectMake(0, 0, KSCREENWidth, KSCREENHeight);
        self.backgroundColor = RGBACOLOR(89, 89, 89, .5);
        
        CGFloat space = 40;
        
        CGFloat imagesize = 180;
        
        UIView *backview = [[UIView alloc]initWithFrame:CGRectMake(0, 0, KSCREENWidth-2*space, 230)];
        backview.backgroundColor = [UIColor whiteColor];
        [df layerWithView:backview radius:6 width:0 color:nil];
        [self addSubview:backview];
        backview.userInteractionEnabled = YES;

        
        UILabel *titleLabel = [UILabel initWithFrame:CGRectMake(0, imagesize*2/3+20, backview.frame.size.width, 40) text:@"注册成功" font:25 textAlignment:NSTextAlignmentCenter texcolor:RGBACOLOR(193, 193, 193, 1) backgroundColor:nil];
        [backview addSubview:titleLabel];
        
        CGFloat btnspace = 20;
        CGFloat btnHeight = 50;
        UIButton *LoginBtn =[[UIButton alloc] initWithFrame:CGRectMake(btnspace, KVIEW_Y(titleLabel)+20 , (backview.frame.size.width-2*btnspace), btnHeight)];
        LoginBtn.backgroundColor =RGBACOLOR(227, 68, 40, 1);
        [LoginBtn setTitle:@"购买激活码" forState:UIControlStateNormal];
        [LoginBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        //[df layerWithView:LoginBtn radius:4 width:2 color:RGBACOLOR(172,134,171, 1)];
        [LoginBtn addTarget:self action:@selector(gotojihuoV:) forControlEvents:UIControlEventTouchUpInside];
        LoginBtn.tag = 10002;
//        [backview addSubview:LoginBtn];
        [df layerWithView:LoginBtn radius:btnHeight/2 width:0 color:nil];
        
        UIButton *shuruBtn =[[UIButton alloc] initWithFrame:CGRectMake(btnspace, KVIEW_Y(titleLabel)+20 , (backview.frame.size.width-2*btnspace), btnHeight)];
        [shuruBtn setTitle:@"填写激活码" forState:UIControlStateNormal];
        [shuruBtn setTitleColor:RGBACOLOR(227, 68, 40, 1) forState:UIControlStateNormal];
        [shuruBtn addTarget:self action:@selector(gotojihuoV:) forControlEvents:UIControlEventTouchUpInside];
        shuruBtn.tag = 10003;
        [backview addSubview:shuruBtn];
        [df layerWithView:shuruBtn radius:btnHeight/2 width:1 color:RGBACOLOR(227, 68, 40, 1)];

        backview.frame = CGRectMake(0, 0, KSCREENWidth-2*space, KVIEW_Y(shuruBtn)+20+imagesize/2);
        backview.center = CGPointMake(KSCREENWidth/2, KSCREENHeight/2);

        UIImageView *imagev = [[UIImageView alloc]initWithFrame:CGRectMake((KSCREENWidth-imagesize)/2, backview.frame.origin.y-imagesize/3, imagesize, imagesize)];
        imagev.userInteractionEnabled = YES;
        imagev.image = [UIImage imageNamed:@"jihuoma.png"];
        [df layerWithView:imagev radius:imagesize/2 width:0 color:nil];
        [self addSubview:imagev];

        
        
    }
    
    return self;
}

- (void)gotojihuoV:(UIButton *)sender{
    [self hiddenView];
    [self.delegate gotoJiHuoWithJihuomaType:(sender.tag == 10002)?LiJiType:TianxieType];
}

- (void)hiddenView{
    
    self.hidden = YES;
    
}

- (void)show{
    self.hidden = NO;
    [[JTCSMSingle shareSingle].theWindow addSubview:[JiHuoMaView shareSingle]];
}

@end
